package com.tang.lts.core.nio.handler;

import com.tang.lts.core.nio.channel.NioChannel;
import com.tang.lts.core.nio.idle.IdleState;

/**
 * @author Tang
 * @classname NioHandler
 * @description [ 定义了处理连接时的动作方法 ]
 * @date 2022/5/12 22:50
 */
public interface NioHandler {

    /**
     * 处理异常时
     *
     * @param channel
     * @param cause
     */
    void exceptionCaught(NioChannel channel, Exception cause);

    /**
     * 消息接收时
     * @param channel
     * @param msg
     * @throws Exception
     */
    void messageReceived(NioChannel channel, Object msg) throws Exception;

    /**
     * 连接时
     * @param channel
     */
    void channelConnected(NioChannel channel);

    /**
     * 读写状态
     * @param channel
     * @param state
     */
    void channelIdle(NioChannel channel, IdleState state);

}
